import { reqDetailInfo } from "@/api"
const state = {
      itemInfo:{}
}
const mutations = {
    GETITEMINFO(state,itemInfo){
        state.itemInfo=itemInfo
        console.log(state.itemInfo);
    }
}
const actions = {
   async getItemInfo({commit},skuId){
        let result= await reqDetailInfo(skuId)
        if(result.code=200){
            commit('GETITEMINFO',result.data)
        }
    }
}
const getters = {
    categoryView(state){
        return state.itemInfo.categoryView || {}
    },
    skuInfo(state){
        return state.itemInfo.skuInfo || {}
    },
    spuSaleAttrList(state){
        return state.itemInfo.spuSaleAttrList || {}
    }
}
export default {
    state,
    actions,
    mutations,
    getters
}